package com.baijia.tianxiao.push.dao.mybatis;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import com.baijia.tianxiao.push.dao.mybatis.base.BaseMapper;
import com.baijia.tianxiao.push.model.PushChannelConfig;

/**
 * 
 * PushChannelAppMapper数据库操作接口类
 * 
 **/

public interface PushChannelConfigMapper extends BaseMapper{


	String allColumns = " id,channel_type,device_type,app_id,develop_status,app_name,app_key,app_package,app_secret,create_time,update_time,status ";
	/**
	 * 
	 * 查询（根据主键ID查询）
	 * 
	 **/
	PushChannelConfig  selectByPrimaryKey (Long id );

	/**
	 * 
	 * 删除（根据主键ID删除）
	 * 
	 **/
	int deleteByPrimaryKey (Long id );

	/**
	 * 
	 * 添加
	 * 
	 **/
	int insert( PushChannelConfig record );

	/**
	 * 
	 * 添加 （匹配有值的字段）
	 * 
	 **/
	int insertSelective( PushChannelConfig record );

	/**
	 * 
	 * 修改 （匹配有值的字段）
	 * 
	 **/
	int updateByPrimaryKeySelective( PushChannelConfig record );

	/**
	 * 
	 * 修改（根据主键ID修改）
	 * 
	 **/
	int updateByPrimaryKey ( PushChannelConfig record );
	
	/**
	 * 根据状态查询所有推送app信息
	 * 
	 * @param status
	 * @return
	 */
	@ResultMap("pushChannelConfigResultMap")
	@Select("select "+allColumns+" from push_channel_config where status=#{status}")
	List<PushChannelConfig> queryAllByStatus(@Param("status") Integer status);
	
	/**
	 * 单条app推送配置查询
	 * 
	 * @param channelType
	 * @param appId
	 * @return
	 */
	@ResultMap("pushChannelConfigResultMap")
	@Select("select "+allColumns+" from push_channel_config where channel_type=#{channelType} and device_type=#{deviceType} and app_id=#{appId} and develop_status=#{developStatus}")
	PushChannelConfig getByChannelTypeAndId(@Param("channelType")String channelType, @Param("deviceType")String deviceType, @Param("appId")String appId,@Param("developStatus")Integer developStatus);

}